<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // 4.原型链继承
    var animal = {
      name: "动物",
      age: 1
    }
    var car = {
      name: "奔驰",
      color: "红色"
    }
    // 原型链继承
    function sub(obj) {
      function Cat() { }
      Cat.prototype = obj
      return new Cat()
    }
    // 类似于复制一个对象，用函数来包装。
    var tom = sub(animal)
    console.log(tom)
    var ben = sub(car)




  </script>
</body>

</html>